package com.mj.haier.calc.interceptor;


import org.hibernate.EmptyInterceptor;
import org.hibernate.EntityMode;
import org.hibernate.type.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * ShardInterceptor hibernate PrepareStatement 时根据注解标示上的策略进行处理表名
 * @author ycm
 */
public class ShardInterceptor extends EmptyInterceptor {

    private static final long serialVersionUID  = -1L;
    private static Logger logger = LoggerFactory.getLogger(ShardInterceptor.class);
    /**
     * 无参构造器
     */
    public ShardInterceptor(){}

    @Override
    public String onPrepareStatement(String sql) {
        logger.info("分表前的sql: \n {}", sql);
        return super.onPrepareStatement(sql);
    }
}
